#include <iostream>
#include <string>
#include "boost/lexical_cast.hpp"
#include "boost/asio.hpp"
using namespace boost;
//void use_const_buffer()
//{
//    asio::const_buffer cb = asio::buffer("hello");
//
//}
//void write_to_socket(asio::ip::tcp::socket& sock)
//{
//    std::string buffer("hello world");
//    size_t writenum = 0;
//    while (writenum != buffer.length())
//    {
//        writenum += sock.write_some(asio::buffer(buffer.c_str() + writenum, buffer.length() - writenum));
//    }
//}
//
//int send_some_by_write_some()
//{
//    std::string ip("127.0.0.1");
//    size_t port = 3333;
//    try {
//        asio::ip::tcp::endpoint ep(asio::ip::make_address(ip), port);
//        asio::io_context ioc;
//    asio::ip::tcp::socket sock(ioc, ep.protocol());
//    sock.connect(ep);
//    write_to_socket(sock);
//
//    }
//    catch (system::system_error& e)
//    {
//
//    }
//}
//int main()
//{
//    using namespace std;
//    cout << "Enter your weight: ";
//    float weight;
//    cin >> weight;
//    string gain = "A 10% increase raises ";
//    string wt = boost::lexical_cast<string> (weight);
//    gain = gain + wt + " to ";      // string operator()
//    weight = 1.1 * weight;
//    gain = gain + boost::lexical_cast<string>(weight) + ".";
//    cout << gain << endl;
//    system("pause");
//    return 0;
//}
unsigned short port = static_cast<unsigned short>(8080);
#include"CServer.h"
#include"ConfigMgr.h"
int main()
{
	try {
		net::io_context ioc{ 1 };
		auto& gcfgMgr = ConfigMgr::Inst();
		//boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
		//signals.async_wait([&ioc](const boost::system::error_code ec, int signal_number) {
		//	if (ec)
		//		return; 

		//	ioc.stop();
		//	});
		std::make_shared<CServer>(ioc, port)->Start();
		ioc.run();
	}
	catch (std::exception ecp)
	{
		std::cerr << "Error:" << ecp.what() << std::endl;
	}

}